<template>
  <div class="check-action-history">
    <el-row>
      <el-col :span="24">
        <dynForm
          :info-form="infoForm"
          :search-tags="searchTags"
          :select-list="selectList"
        >
          <el-button
            type="primary"
            icon="el-icon-search"

            @click="doSearch"
          >
            {{ $t('search') }}</el-button>
        </dynForm>
      </el-col>
    </el-row>
    <el-card>
      <el-row>
        <dynTable
          ref="dynTable"
          :loading="tableLoading"
          :table-data="tableData"
          :table-columns="tableColumns"
        />
      </el-row>
      <pagination
        :page.sync="listQuery.page"
        :size.sync="listQuery.size"
        :total="total"
        @pagination="getList"
      />
    </el-card>
  </div>
</template>
<script>
import mySetting from '@/mixins/mySetting'
import { getList, getActionIDAndNameList } from '@/api/checkManagement/checkActionHistory'
export default {
  name: 'CheckActionHistory',
  mixins: [mySetting],
  data() {
    const searchTags = [
      { label: this.$t('workOrder'), prop: 'workOderNo', tag: 'DynInput' },
      { label: this.$t('ActionName'), prop: 'actions', tag: 'DynSelect' },
      { label: this.$t('timeInterval'), prop: '', tag: 'Dyndaterange', event: (value) => {
        this.infoForm.startTime = Array.isArray(value) ? value[0] : null
        this.infoForm.endTime = Array.isArray(value) ? value[1] : null
      } },
      { label: this.$t('formNo'), prop: 'formNo', tag: 'DynInput' }
    ]
    const tableColumns = [
      // { prop: '', label: '', type: 'selection' },
      { prop: '', label: this.$t('index'), type: 'index', width: '50px', templete: (_scope) => {
        return (
          <span>{ (this.listQuery.page - 1) * this.listQuery.size + _scope.$index + 1 }</span>
        )
      } },
      { prop: 'workOderNo', label: this.$t('workOrder') },
      { prop: 'checkFormNo', label: this.$t('formNo') },
      { prop: 'eqpName', label: this.$t('handlerId') },
      { prop: 'testEqpName', label: this.$t('testerId') },
      { prop: 'actionName', label: this.$t('ActionName') },
      { prop: 'createTime', label: this.$t('createTime') }
    ]
    return {
      infoForm: {},
      selectList: {},
      searchTags: Object.freeze(searchTags),
      tableColumns: Object.freeze(tableColumns),
      tableLoading: true
    }
  },
  created() {
    this.initList()
    // this.getActionsList()
  },
  methods: {
    async initList() {
      const res = await getList(this.$clearNull({ ...this.listQuery, ...this.infoForm }))
      this.tableData = res.data
      this.total = res.total
      this.tableLoading = false
    },
    doSearch() {
      this.listQuery.page = 1
      this.initList()
    },
    doAdd() {
      // this.$refs.tpirftForm.handleOpen()
    },
    handleEdit() {
      // this.$refs.tpirftForm.handleOpen(this.multipleSelection[0])
    },
    handleDelete() {
      this.$confirm(
        `${this.$t('confirmDelete')}${this.multipleSelection.length}${this.$t(
          'recordCount'
        )}?`,
        this.$t('tip'),
        {
          confirmButtonText: this.$t('confirm'),
          cancelButtonText: this.$t('cancel'),
          type: 'warning'
        }
      ).then(() => {
      })
    },
    getList(page) {
      this.listQuery = page
      this.initList()
    },
    async getActionsList() {
      const res = await getActionIDAndNameList()
      this.$set(this.selectList, 'actions', res.data)
    }

  }
}
</script>
<style lang="scss" scoped>
@import "~@/assets/styles/defaultStyle.scss";
::v-deep .el-row:nth-child(1) {
  padding-bottom: 0;
}
::v-deep .el-form {
  padding-top: 10px;
  // .el-form-item {
  //   margin-bottom: 15px;
  // }
}
</style>
